<?php
class Del_View_Helper_PromoProductos 
	extends Zend_View_Helper_Abstract
{
	public function promoProductos( $promocionProductos )
	{
		$text = '<p class="promoProducts">';
		
		$groups = array();
		
		
		if( !empty($promocionProductos)){
						
			foreach($promocionProductos as $p){
				
				$categoria = $p->getCategoria();
				
				if( !isset($groups[$categoria->nombre])){
					$groups[$categoria->nombre] = array();
				}
				
				$groups[$categoria->nombre][] = "{$p->cantidad} x {$p->nombre}";
				
			}
			
			foreach($groups as $categoria=>$group){
				
				$text.="{$categoria}: " . implode(",",$group) . "; ";
			}
			
		}
		
		$text.="</p>";
		
		return $text;			
	}
}